import 'dart:convert';

import 'package:book_app/product/dio_http/achttp.dart';
import 'package:book_app/product/models/userInfo.dart';

class LoginService {
  late UserInfo userInfo; //用户信息
  Future<UserInfo> login(String account, String pwd) async {
    ACHttp.getInstance().post("/APP/Account/login", {
      "account": account,
      "pwd": pwd,
      "udid": "2C2D3BA4-A311-41C5-95B6-6F5959EF8549",
      "version": "16.3.1",
      "device": "iPhone10,1"
    }).then((response) {
      // DO SOMETHING
      if (response is Result) {
        Result result = response;
        final data = result.data;
        final Map<String, dynamic> booksData = data['data'];
        userInfo = UserInfo.fromJson(booksData);
        print('LoginService ${userInfo.toString()}');
        return userInfo;
      }
    }).catchError((err) {
      // DO SOMETHING
    });
    return userInfo;
  }
}
